package com.zzzyh.forumsystemclient.cotroller;

import com.zzzyh.forumsystemclient.common.AppResult;
import com.zzzyh.forumsystemclient.model.Album;
import com.zzzyh.forumsystemclient.model.Photo;
import com.zzzyh.forumsystemclient.services.IAlbumService;
import com.zzzyh.forumsystemclient.services.IPhotosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/album")
public class AlbumController {

    @Autowired
    private IAlbumService albumService;
    @Autowired
    private IPhotosService photosService;
    @RequestMapping("/list")
    public AppResult<List<Album>> list() {
        return AppResult.success(albumService.list());
    }

    @RequestMapping("/detail/{albumId}")
    public AppResult<Album> detail(@PathVariable Long albumId) {
        return AppResult.success(albumService.getById(albumId));
    }

    @RequestMapping("/photos/{albumId}")
    public AppResult<List<Photo>> photos(@PathVariable Long albumId) {
        return AppResult.success(photosService.getPhotosByAlbumId(albumId));
    }
}
